{% extends 'buyer/base.html' %}

{% block title %}
    购物车
{% endblock %}

{% block content %}

	<div class="total_count">全部商品<em>{{ count }}</em>件</div>
	<ul class="cart_list_th clearfix">
		<li class="col01">商品名称</li>
		<li class="col02">商品单位</li>
		<li class="col03">商品价格</li>
		<li class="col04">数量</li>
		<li class="col05">小计</li>
		<li class="col06">操作</li>
	</ul>
    <form action="/Buyer/pay_order_more/">
    {% for g in goods %}
	<ul class="cart_list_td clearfix">
		<li class="col01"><input class="goods_check" type="checkbox" name="check_{{ g.goods_id }}"></li>
		<li class="col02"><img src="/static/{{ g.goods_picture }}"></li>
		<li class="col03">{{ g.goods_name }}<br><em>{{ g.goods_price }}元/500g</em></li>
		<li class="col04">500g</li>
		<li class="col05">{{ g.goods_price }}元</li>
		<li class="col06">
			<div class="num_add">
				<a href="javascript:;" class="add fl">+</a>
				<input type="text" class="num_show fl" value="{{ g.goods_number }}" name="count_{{ g.id }}">
				<a href="javascript:;" class="minus fl">-</a>
			</div>
		</li>
		<li class="col07">{{ g.goods_total }}元</li>
		<li class="col08"><a href="javascript:;">删除</a></li>
	</ul>
    {% endfor %}
	<ul class="settlements">
		<li class="col01"><input type="checkbox" id="allBox" name=""></li>
		<li class="col02">全选</li>
		<li class="col03">合计(不含运费)：<span>¥</span><em>42.60</em><br>共计<b>{{ count }}</b>件商品</li>
		<li class="col04"><input type="submit" value="去结算"></li>
	</ul>
    </form>
{% endblock %}
{% block script %}
    <script>
        $("#allBox").click(
            function () {
                //this.checked //true代表选中，false没有选中
                if(this.checked){
                    $(".goods_check").prop("checked",true)
                }else {
                    $(".goods_check").prop("checked",false)
                }
            }
        );
        $(".goods_check").each(
            function () {
                $(this).click(
                    function () {
                        if(!this.checked){
                            $("#allBox").prop("checked",false)
                        }
                    }
                )
            }
        )
    </script>
{% endblock %}